<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
		<div id="app">
			
		
			<!-- 计算属性 -->
			<h2>{{fullName}}</h2>
		</div>
		<script src="../js/vue.js" type="text/javascript"></script>
		<script type="text/javascript">
			const app = new Vue({
				el: "#app",
				data:{
					firstName : 'Lebron',
					lastName: 'James'
				},
				// 用属性起名字
				computed:{
					// 简写属性 只有get方法
					// fullName : function(){
					// 	return this.firstName + ' ' + this.lastName
					// }
					fullName:{	
						// 只读写法 ,对应上述
						get:function(){
							return this.firstName + ' ' + this.lastName;
						},
						// set,当控制器修改fullName时调用app.
						set:function(newValue){
							// return this.firstName + ' ' + this.lastName
							console.log('----',newValue);
							const names = newValue.split(' ');
							this.firstName = names[0];
							this.lastName = names[1];
						}
					}
				}
			})
		</script>
	</body>
</html>
